#include "sudoku_group.h"

//------------------------------------------------------------------------------------------------------------
void GroupUnique::updateAvailableSet(set<int,ValuesCmp<vector<int>* > >* availableSet, map<int,SudokuField*>* psudokuBoard, int emptyValue)
{
	set<int>::iterator sit;
	BOOST_FOREACH(int idx, fieldsIndices)
	{
		if(*(*psudokuBoard)[idx]->value != emptyValue)
		{
			sit = availableSet->find(*(*psudokuBoard)[idx]->value);
			if(sit != availableSet->end())
				availableSet->erase(sit);
		}
	}
}
//------------------------------------------------------------------------------------------------------------
void GroupAdd::updateAvailableSet(set<int,ValuesCmp<vector<int>* > >* availableSet, map<int,SudokuField*>* psudokuBoard, int emptyValue)
{
	set<int>::iterator sit;
	int sum = 0;

	BOOST_FOREACH(int idx, fieldsIndices)
	{
		sum += *(*psudokuBoard)[idx]->value;
	}

	BOOST_FOREACH(int v, *availableSet)
	{
		if(v != emptyValue)
		{
			if(sum + v > expectedSum)
				availableSet->erase(v);
		}
	}
}
//------------------------------------------------------------------------------------------------------------
void Group::print()
{
	cout << "group: fieldsIndices(";
	BOOST_FOREACH(int v, fieldsIndices)
	{
		cout << v << " ";
	}
/*
	cout << "),possibleValues(";
	BOOST_FOREACH(int v, *possibleValues)
	{
		cout << v << " ";
	}
*/
/*
	cout << "),possibleIndices(";
	BOOST_FOREACH(int v, *possibleIndices)
	{
		cout << v << " ";
	}
*/
	cout << ")\n";
}
//------------------------------------------------------------------------------------------------------------
